package com.zhai.cloud.client;


import com.zhai.cloud.starter.snowflake.work.SnowflakeWorker;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author Created by 翟凤玺
 * @package com.zhai.cloud.client
 * @project-name zhai-cloud
 * @description //TODO 请对该类编写一个描述
 * @create-datetime 2019-9-29 16:55
 */
@SpringBootApplication(scanBasePackages = {"com.zhai.cloud"})
@EnableEurekaClient
public class ClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }

    @RefreshScope
    @RestController
    public class ClientController {
        @Value("${name}")
        private String name;

        @Value("${age}")
        private String age;

        @Autowired
        SnowflakeWorker snowflakeWorker;

        @GetMapping("/config")
        public String config() {
            long s = snowflakeWorker.nextId();
            return this.name + this.age + " snowflakeWorker:" + s;
        }
    }
}
